﻿
/*
 @    Author : Rich of BeastModeMS
 @
 @    NPC = Mr. Oh
 @    Map =  MAP
 @    NPC MapId = MAPID
 @    Function = All in one Shop
 @
 */
var itemList = Array(
1142878, 
1142879,
1142880,
1142881,
1142882,
1142883,
1142884);//25
var status = 0;
var input = 0;
var statusA = 0;
var ed = false;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    var nx = cm.getChar().getCSPoints(1);
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (ed == true && !cm.getPlayer().isGM()) {
            cm.sendOk("兌換NPC維修中，若造成不便請多多包涵。");
            cm.dispose();
            return;
        }
        if (status == 0) {

var id =cm.getPlayer().getId();
       var r1=cm.MissionGetFinish(id,5278);
     var r2=cm.MissionGetFinish(id,5279);
var text = "";
      





 cm.sendOk("要兌換哪個呢?\r\n"+
"#L0##i1142878##e#z1142878##n 擊敗烏魯斯1次#b("+r1+"/1)\r\n"+
"#L1##k#i1142879##e#z1142879##n 擊敗烏魯斯10次#b("+r1+"/10)\r\n"+

"#L2##k#i1142881##e#z1142881##n 擊敗烏魯斯50次#b("+r1+"/100)\r\n"+
"#L3##k#i1142880##e#z1142880##n 擊敗烏魯斯100次#b("+r1+"/50)\r\n"+
"#L4##k#i1142882##e#z1142882##n 獲得sss級1次#b("+r2+"/1)\r\n"+
"#L5##k#i1142883##e#z1142883##n 獲得sss級10次#b("+r2+"/10)\r\n"+
"#L6##k#i1142884##e#z1142884##n 獲得sss級20次次#b("+r2+"/30)\r\n");
cm.MissionFinish(1,3233);
 


                          
        } else if (status == 1) {
for(var i=1; i<itemList.length; i++) {
	     if(!cm.canHold(itemList[i], 1)){
             cm.sendOk("您的背包滿了 請確認背包(裝備、消耗、其它、設置、特殊欄位)都有留一格空位或是身上以有相同勳章");
             cm.dispose();
             return;   
             }
		}
   var id =cm.getPlayer().getId();
       var r1=cm.MissionGetFinish(id,5278);
     var r2=cm.MissionGetFinish(id,5279);
	

            if (selection == 0) {
                if (cm.MissionGetFinish(id,5278)>=1) {

                    cm.gainItem(1142878, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
           } else if (selection == 1) {
                   if (cm.MissionGetFinish(id,5278)>=10) {

                    cm.gainItem(1142879, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
        
         } else if (selection == 2) {
                if (cm.MissionGetFinish(id,5278)>=50) {

                    cm.gainItem(1142881, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
         } else if (selection == 3) {
                  if (cm.MissionGetFinish(id,5278)>=100) {

                    cm.gainItem(1142880, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
         } else if (selection == 4) {
                   if (cm.MissionGetFinish(id,5279)>=1) {

                    cm.gainItem(1142882, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
         } else if (selection == 5) {
                  if (cm.MissionGetFinish(id,5279)>=10) {

                    cm.gainItem(1142883, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
         } else if (selection == 6) {
                  if (cm.MissionGetFinish(id,5279)>=30) {

                    cm.gainItem(1142884, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("次數不足夠!");
                    cm.dispose();
                }
                          } else if (selection == 7) {
                if (cm.haveItem(4009354,30)&&cm.haveItem(4009355,30)&&cm.haveItem(4009356,20)&&cm.haveItem(4009348,3)&&cm.haveItem(4009353,10)) {
                    cm.gainItem(4009354, -30);
                    cm.gainItem(4009355, -30);
                    cm.gainItem(4009356, -20);
                    cm.gainItem(4009348, -3);
                    cm.gainItem(4009353, -10);
                    cm.gainItem(2049705, 1);
                    cm.sendOk("兌換成功!");

                    cm.dispose();
                } else {
                    cm.sendOk("你身上材料不足夠!");
                    cm.dispose();
                }

     
         
            }

}
}
}
